using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.IO;
using System.Web.UI.HtmlControls;
using Library.WebControls.SimpleButton;


namespace Library.WebControls.SimpleUpload {
	public class SpUploadDesign : System.Web.UI.Design.ControlDesigner {
		public override string GetDesignTimeHtml() {
			SpUpload tv = (SpUpload)Component;
			StringWriter sw = new StringWriter();
			HtmlTextWriter html = new HtmlTextWriter(sw);

			HtmlGenericControl div = CreateUpload(tv);
			
			
			tv.CreateCssLink().RenderControl(html);
			tv.UploadButton.CreateCssLink().RenderControl(html);


			div.RenderControl(html);
			return sw.ToString();
		}

		private HtmlGenericControl CreateUpload(SpUpload up) {
			HtmlGenericControl divMainUpload = new HtmlGenericControl("div");
			divMainUpload.Attributes["class"] = "spupload";

			HtmlGenericControl divInput = new HtmlGenericControl("div");
			divMainUpload.Controls.Add(divInput);
			divInput.Attributes["class"] = "spuploadText";
			TextBox textUpload = new TextBox();
			textUpload.Width = up.Width;
			textUpload.Enabled = false;
			divInput.Controls.Add(textUpload);
			HtmlGenericControl divButton = new HtmlGenericControl("div");
			divButton.Attributes["class"] = "spuploadbutton";
			SpButton uploadButton = new SpButton();
			uploadButton.Visible = up.UploadButton.Visible;
			uploadButton.ImageUrl = up.UploadButton.ImageUrl;
			uploadButton.Text = up.UploadButton.Text;
			divButton.Controls.Add(uploadButton);

			divMainUpload.Controls.Add(divButton);
			
			return (divMainUpload);
		}
	}
}
